package thread;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ThreadPool {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
        Executors.newCachedThreadPool();
//        Executors.newScheduledThreadPool();
        Executors.newFixedThreadPool(10);


        System.out.printf("起始时间：%s\n\n", new SimpleDateFormat("HH:mm:ss").format(new Date()));
        // 延时 1 秒后，按 3 秒的周期执行任务
        scheduledExecutor.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                System.out.println("执行时间" + new SimpleDateFormat("HH:mm:ss").format(new Date()));
                System.out.println("xcc");
            }
        }, 1000, 3000, TimeUnit.MILLISECONDS);
    }
}
